package cn.iocoder.yudao.module.vlog.info.controller.admin;

import cn.iocoder.yudao.framework.business.basic.pojo.vo.UserSimpleVO;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.api.member.user.MemberUserApi;
import cn.iocoder.yudao.module.vlog.info.service.VLogInfoService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@Tag(name = "管理后台 - 视频收藏")
@RestController
@RequestMapping("/vlog/favorite")
@Validated
public class VLogFavoriteController {

    @Resource
    private VLogInfoService infoService;
    @Resource
    private MemberUserApi memberUserApi;

    @GetMapping("/list-user")
    @Operation(summary = "获得视频收藏的用户列表")
    @Parameter(name = "vlogId", description = "视频编号", required = true, example = "1024")
    @PreAuthorize("@ss.hasPermission('vlog:favorite:query')")
    public CommonResult<List<UserSimpleVO>> getUserList(Long vlogId) {
        List<Long> userIds = infoService.getVLogCollectUserIds(vlogId);
        return success(memberUserApi.getUserSimpleList(userIds));
    }

}
